<div style="padding-bottom:20px;" class="button_section">
       <div class="left width65p componentheading"><?php echo $page_title;?></div>
       <div class="width30p" style="float:right;text-align: right;">
       <?php if($this->session->userdata('pub_admin_login_id')){ ?>
            <a href="<?php echo site_url('login/logout');?>">Logout</a>
       <?php }else{?>
           <a href="<?php echo site_url('login');?>">Login as admin</a>
       <?php }?>
       </div>
       <div class="clear"></div>
</div>
<div><?php global_message(); ?></div>
<div class="padding_10bottom">
<?php $keyword = "title or publisher";?>
<form method="get" onsubmit="if($('#keyword').val()== '<?php echo $keyword;?>') $('#keyword').val('');">
	<div class="left width250">
    	<input type="text" id="keyword" name="Search" onblur="if (this.value=='') this.value = '<?php echo $keyword;?>'"  onfocus="if (this.value=='<?php echo $keyword;?>') this.value = ''" value="<?php if($search) echo $search; else echo $keyword;?>" class="" />
    </div>
	<div class="left width250">
    	<select name="thematicArea" style="width:200px;">
        <option value="all">All</option>
        <?php echo $area;?>
        <?php 
		if(count($categories) > 0) :
			foreach($categories as $category):
		?>
	        <option value="<?php echo $category->id;?>" <?php if($area == $category->id) echo 'selected="selected"';?>><?php echo $category->category_name;?></option>
            <?php
				$sub_categories = $this->general_db_model->getAll('tbl_publication_category', 'category_name', 'parent_id = '.$category->id);
				
				if(count($sub_categories) > 0)
				{
					echo "<optgroup>";
					foreach($sub_categories as $sub)
					{
						echo '<option value="'.$sub->id.'" ';
								if($area == $sub->id) echo 'selected="selected"';
						echo '>'.$sub->category_name.'</option>';
					}
					echo "</optgroup>";
				}
						
			?>
        <?php endforeach; ?>
        <?php endif; ?>
        </select>
    </div>
    <div class="left">
    	<input type="submit" value="Search" />
    </div>
    </form>
    <div style="clear:both;"></div>
</div>

<div class="box-header">Publications List</div>
    <div class="box table">
		<table cellspacing="0" width="100%">
	    <thead>
            <tr>
            	<!--<td width="2%" rowspan="2"><input type="checkbox" name="check_all" id="check_all" value="1" /></td>
              	--><td width="3%" rowspan="2" class="noLeftBorder">&nbsp;</td>
                <td width="45%" rowspan="2" class="noLeftBorder">Publication</td>
                <td width="13%" rowspan="2">Publisher</td>
                <td width="7%" rowspan="2">Pages</td>
                <td width="7%" rowspan="2">Year of Publication</td>
                <td colspan="2">Total Quantity</td>
                <td width="10%" rowspan="2">Options</td>
          </tr>
            <tr>
              <td width="5%">English</td>
              <td width="10%">Nepali</td>
            </tr>
		</thead>
        <tbody>
        <?php if($total_publications > 0) : ?>
        	<?php foreach($publications as $publication) : ?>
        	<tr>
            	<!--<td><input type="checkbox" name="check_<?php echo $publication->id;?>" id="check_<?php echo $publication->id;?>" class="check_row" value="<?php echo $publication->id;?>" /></td>
             -->
            	<td class="noLeftBorder"><img src="<?php echo get_image(config_item('publication_thumbs_path'), $publication->image);?>" /></td>
                <td class="noLeftBorder">
                	<div><a href="<?php echo action_link('details', $publication->id);?>"><?php echo $publication->title;?></a></div>
                	<div><span class="small padding_0left">Coding:</span><strong><?php echo $publication->coding;?></strong></div>
                    <div><span class="small padding_0left">Thematic Area:</span><strong><?php echo $publication->thematic_area;?></strong></div>
                    <?php if($publication->sub_thematic_area) : ?>
                    <div><span class="small padding_0left">Sub-thematic Area:</span><strong><?php echo $publication->sub_thematic_area;?></strong></div>
                    <?php endif;?>
                </td>
                <td><?php echo $publication->publisher;?>&nbsp;</td>
                <td><?php echo $publication->pages;?></td>
                <td><?php echo $publication->publish_year;?></td>
                <td><?php echo quantity($publication->id, 'en', 'total_qty');?></td>
                <td><?php echo quantity($publication->id, 'np', 'total_qty');?></td>
                <td>
                    <div><a href="<?php echo action_link('details', $publication->id);?>">Details</a></div>
                     <?php if($publication->soft_copy!="" && $publication->soft_copy_type=="upload"){?>
                    <div><a href="<?php echo base_url().'uploads/softcopy/'.$publication->soft_copy;?>" target="_blank">Download</a></div>
                    <?php }elseif($publication->soft_copy!="" && $publication->soft_copy_type=="url"){?>
                    <div><a href="<?php echo $publication->soft_copy;?>" target="_blank">Download</a></div>
                    <?php }?>
                </td>
            </tr>
            <?php endforeach; ?>
        <?php else : ?>
        	<tr>
            	<td colspan="5" class="noLeftBorder">
                    <div class="error_message">
                 		No Publications available.
                    </div>
                </td>
            </tr>
        <?php endif; ?>
                
	    </tbody>
	</table>        
  </div>
<div id="pagination">
	<?php echo $this->pagination->create_links(); ?>
</div>
